package com.puppet.building.service.impl;

import com.puppet.building.handler.MyAssert;
import com.puppet.building.mapper.BuildingMapper;
import com.puppet.building.mapper.OwnerMapper;
import com.puppet.building.pojo.Building;
import com.puppet.building.pojo.MyPageData;
import com.puppet.building.pojo.Owner;
import com.puppet.building.pojo.enums.BuildingCode;
import com.puppet.building.pojo.vo.OwnerVO;
import com.puppet.building.service.BuildingService;
import com.puppet.building.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OwnerServiceImpl implements OwnerService {

    @Autowired
    private OwnerMapper ownerMapper;

    @Override
    public List<Owner> getAllOwner() {
        return ownerMapper.getAllOwner();
    }

    @Override
    public Integer addNewOwner(Owner owner) {
        Integer result = ownerMapper.addNewOwner(owner);
        MyAssert.error(result <=0, BuildingCode.SAVE_FAIL.getMessage());
        return result;
    }

    @Override
    public Owner getAllOwnerById(Integer id) {
        return ownerMapper.getAllOwnerById(id);
    }

    @Override
    public Integer updateOwner(Owner owner) {
        Integer result = ownerMapper.updateOwner(owner);
        MyAssert.error(result <=0, BuildingCode.SAVE_FAIL.getMessage());
        return result;
    }

    @Override
    public List<OwnerVO> getOwnerNameAnId() {
        return ownerMapper.getOwnerNameAnId();
    }
}
